/**
 * 
 */
package com.jjt.kiki.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


import com.jjt.kiki.bean.TbRes;
import com.jjt.kiki.service.ResService;
import com.jjt.kiki.util.MyResponseEntityBuilder;
import com.jjt.kiki.util.PageVoUtil;
import com.jjt.kiki.vo.factory.VoListBuilder;
import com.mysql.fabric.Response;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * @author jjtEatJava
 *
 */
@Controller
public class ResController {
	@Autowired
	ResService resService;
	@RequestMapping("/search")
	public ResponseEntity<Map<String,Object>> search(
			String search,
			Integer page,
			 Integer size,
			String sort,
			@PageableDefault(page=0,size=20,sort={"resShareDate"},direction=Sort.Direction.DESC)Pageable pageable
			){
		Page<TbRes> tReses = resService.findAllBySearch(search,pageable);
		return MyResponseEntityBuilder.buildSuccessRes(tReses.getContent(),PageVoUtil.getVo(tReses));
	}
}
